//
// Created by zeng on 2022/1/23.
//

#include "MailAll.h"

MailAll::MailAll(Sender sender, Receiver receiver, TYPE type) : sender{sender}, receiver{receiver} {
    GetWeather getWeather{receiver.location};
    switch (type) {
        case TYPE::WEATHER: {
            Weather weather{getWeather.get_weather()};
            MailContent mailContentTemp1{sender.name, receiver.name, weather};
            this->mailContent = mailContentTemp1;
            break;
        }
        case TYPE::TIP: {
            Tip tip{getWeather.get_tip()};
            MailContent mailContentTemp2{sender.name, receiver.name, tip};
            this->mailContent = mailContentTemp2;
            break;

        }
        case TYPE::WARN: {
            Warn warn{getWeather.get_warn()};
            MailContent mailContentTemp3{sender.name, receiver.name, warn};
            this->mailContent = mailContentTemp3;
            break;
        }
    }
}